package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.ruoyi.system.domain.SysRoleDept;
import com.ruoyi.system.mapper.SysRoleDeptMapper;
import com.ruoyi.system.service.ISysRoleDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysRoleDeptServiceImpl implements ISysRoleDeptService {
    @Autowired
    private SysRoleDeptMapper roleDeptMapper;

    @Override
    public boolean deleteByRoleId(Long roleId) {
        return new LambdaUpdateChainWrapper<>(roleDeptMapper)
                .eq(SysRoleDept::getRoleId, roleId)
                .remove();
    }

    @Override
    public void deleteByRoleIds(List<Long> roleIds) {
        new LambdaUpdateChainWrapper<>(roleDeptMapper)
                .in(SysRoleDept::getRoleId, roleIds)
                .remove();
    }

    @Override
    public List saveList(List<SysRoleDept> list) {
        return roleDeptMapper.insert(list);
    }

    @Override
    public List<SysRoleDept> selectByRoleId(Long roleId) {
        return new LambdaQueryChainWrapper<>(roleDeptMapper)
                .eq(SysRoleDept::getRoleId, roleId)
                .list();
    }
}
